home *** CD-ROM | disk | FTP | other *** search
- CREATE DATABASE "%DBNAME%"
- GO
-
- EXEC sp_dboption "%DBNAME%", N'autoclose', N'true'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'torn page detection', N'true'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'read only', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'dbo use', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'single', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'autoshrink', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'ANSI null default', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'recursive triggers', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'ANSI nulls', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'concat null yields null', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'cursor close on commit', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'default to local cursor', N'true'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'quoted identifier', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'ANSI warnings', N'false'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'auto create statistics', N'true'
- GO
-
- EXEC sp_dboption "%DBNAME%", N'auto update statistics', N'true'
- GO
-
- USE "%DBNAME%"
- GO
-
- CREATE TABLE [DLServers] (
- [ServerId] [int] IDENTITY (1, 1) NOT NULL ,
- [ServerGuid] [uniqueidentifier] NOT NULL ,
- [Url] [nvarchar] (500) NULL ,
- CONSTRAINT [PK_Servers] PRIMARY KEY CLUSTERED (
- [ServerId]
- ) ,
- CONSTRAINT [IX_Servers] UNIQUE NONCLUSTERED (
- [ServerGuid]
- )
- )
- GO
-
- CREATE TABLE [DLStations] (
- [ServerId] [int] NOT NULL ,
- [CompId] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
- [NetworkAddr] [nvarchar] (50) NULL ,
- [Endpoint] [nvarchar] (50) NULL ,
- [LastScanTime] [datetime] NULL ,
- [NeedToScan] [bit] NOT NULL DEFAULT (1) ,
- [AttemptsCount] [int] NOT NULL DEFAULT (0) ,
- CONSTRAINT [PK_Stations] PRIMARY KEY CLUSTERED (
- [ServerId],
- [CompId]
- )
- )
- GO
-
- CREATE TABLE [DLUsers] (
- [ServerId] [int] NOT NULL ,
- [UserId] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
- [SID] [nvarchar] (255) NOT NULL ,
- [UserName] [nvarchar] (50) NULL ,
- CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED (
- [ServerId],
- [UserId]
- )
- )
- GO
-
- CREATE TABLE [DLShadowFiles] (
- [ServerId] [int] NOT NULL ,
- [ShadowId] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
- [CompId] [int] NOT NULL ,
- [OriginalFileName] [nvarchar] (1500) NULL ,
- [CreationDate] [bigint] NULL ,
- [DeviceType] [int] NULL ,
- [OperationType] [int] NULL ,
- [ProcessName] [nvarchar] (1500) NULL ,
- [Pid] [int] NULL ,
- [StartingOffset] [bigint] NOT NULL DEFAULT (0) ,
- [ShadowSize] [bigint] NOT NULL DEFAULT (0) ,
- [IsFastRebuild] [bit] NOT NULL DEFAULT (0) ,
- [IOErrFile] [image] NULL ,
- [XMLFile] [ntext] NOT NULL ,
- [StoreId] [int] NULL ,
- [Attributes] [int] NOT NULL DEFAULT (0) ,
- [Status] [int] NOT NULL DEFAULT (0) ,
- [DeletionDate] [bigint] NULL ,
- [DelUserId] [int] NULL ,
- [DelCompId] [int] NULL ,
- CONSTRAINT [PK_ShadowFiles] PRIMARY KEY CLUSTERED (
- [ServerId],
- [ShadowId]
- ) ,
- CONSTRAINT [IX_ShadowFiles] UNIQUE NONCLUSTERED (
- [ServerId],
- [ShadowId]
- )
- )
- GO
-
- CREATE TABLE [DLShadowFiles_Users] (
- [ServerId] [int] NOT NULL ,
- [ShadowId] [int] NOT NULL ,
- [UserId] [int] NOT NULL ,
- [Flag] [int] NOT NULL DEFAULT (0) ,
- CONSTRAINT [PK_ShadowFiles_Users] PRIMARY KEY CLUSTERED (
- [ServerId],
- [ShadowId],
- [UserId]
- )
- )
- GO
-
- CREATE TABLE [DLStore] (
- [ServerId] [int] NOT NULL ,
- [StoreId] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
- [DataSize] [bigint] NOT NULL DEFAULT (0) ,
- [DigestSHA1] [binary] (20) NULL ,
- [DigestMD5] [binary] (16) NULL ,
- [CRC32] [binary] (4) NULL ,
- [RealSize] [bigint] NOT NULL DEFAULT (0) ,
- [Location] [tinyint] NOT NULL DEFAULT (0) ,
- [ContentType] [int] NULL ,
- CONSTRAINT [PK_Store] PRIMARY KEY CLUSTERED (
- [ServerId],
- [StoreId]
- )
- )
- GO
-
- CREATE TABLE [DLStoreBin] (
- [ServerId] [int] NOT NULL ,
- [StoreId] [int] NOT NULL ,
- [PartId] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
- [Data] [image] NULL ,
- CONSTRAINT [PK_StoreBin] PRIMARY KEY CLUSTERED (
- [ServerId],
- [StoreId],
- [PartId]
- )
- )
- GO
-
- CREATE TABLE [DLStoreUrl] (
- [ServerId] [int] NOT NULL ,
- [StoreId] [int] NOT NULL ,
- [Url] [ntext] NOT NULL ,
- CONSTRAINT [PK_StoreUrl] PRIMARY KEY CLUSTERED (
- [ServerId],
- [StoreId]
- )
- )
- GO
-
- CREATE TABLE [DLEvents] (
- [ServerId] [int] NOT NULL ,
- [EventId] [int] IDENTITY (1, 1) NOT NULL ,
- [LogTime] [datetime] NOT NULL ,
- [Severity] [int] NOT NULL ,
- [EventCode] [int] NULL ,
- [Message] [nvarchar] (1000) NULL ,
- CONSTRAINT [PK_Events] PRIMARY KEY CLUSTERED (
- [ServerId],
- [EventId]
- )
- )
- GO
-
- CREATE TABLE [DLAuditLog] (
- [ServerId] [int] NOT NULL ,
- [RecordId] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
- [CompId] [int] NOT NULL ,
- [UserId] [int] NULL ,
- [CreationDate] [bigint] NULL ,
- [EventId] [int] NULL ,
- [Type] [smallint] NULL ,
- [ProcessName] [nvarchar] (1500) NULL ,
- [Pid] [int] NULL ,
- [DeviceType] [nvarchar] (500) NULL ,
- [Action] [nvarchar] (500) NULL ,
- [Name] [nvarchar] (500) NULL ,
- [Info] [nvarchar] (500) NULL ,
- [CustomData] [ntext] NULL ,
- CONSTRAINT [PK_DLAuditLog] PRIMARY KEY CLUSTERED
- (
- [ServerId],
- [RecordId]
- )
- )
- GO
-
- CREATE TABLE [DLSettings] (
- [Name] [nvarchar] (50) NOT NULL ,
- [Value] [nvarchar] (50) NOT NULL ,
- [ServerId] [int] NULL ,
- [CompId] [int] NULL
- )
- GO
-
- CREATE TABLE [DLSchema] (
- [SchemaVersion] [int] NOT NULL DEFAULT (10)
- )
- GO
-
- INSERT INTO [DLSchema] ([SchemaVersion]) VALUES (17)
-
- GO
-
- ALTER TABLE [DLEvents] ADD
- CONSTRAINT [FK_Events_Servers] FOREIGN KEY
- (
- [ServerId]
- ) REFERENCES [DLServers] (
- [ServerId]
- ) ON UPDATE CASCADE
- GO
-
- ALTER TABLE [DLShadowFiles] ADD
- CONSTRAINT [FK_ShadowFiles_Servers] FOREIGN KEY
- (
- [ServerId]
- ) REFERENCES [DLServers] (
- [ServerId]
- ) ON UPDATE CASCADE ,
- CONSTRAINT [FK_ShadowFiles_Stations] FOREIGN KEY
- (
- [ServerId],
- [CompId]
- ) REFERENCES [DLStations] (
- [ServerId],
- [CompId]
- ),
- CONSTRAINT [FK_ShadowFiles_Store] FOREIGN KEY
- (
- [ServerId],
- [StoreId]
- ) REFERENCES [DLStore] (
- [ServerId],
- [StoreId]
- ),
- CONSTRAINT [FK_DelShadowFiles_Stations] FOREIGN KEY
- (
- [ServerId],
- [DelCompId]
- ) REFERENCES [dbo].[DLStations] (
- [ServerId],
- [CompId]
- ),
- CONSTRAINT [FK_DelShadowFiles_Users] FOREIGN KEY
- (
- [ServerId],
- [DelUserId]
- ) REFERENCES [dbo].[DLUsers] (
- [ServerId],
- [UserId]
- )
- GO
-
- ALTER TABLE [DLShadowFiles_Users] ADD
- CONSTRAINT [FK_ShadowFiles_Users_Servers] FOREIGN KEY
- (
- [ServerId]
- ) REFERENCES [DLServers] (
- [ServerId]
- ) ON UPDATE CASCADE ,
- CONSTRAINT [FK_ShadowFiles_Users_ShadowFiles] FOREIGN KEY
- (
- [ServerId],
- [ShadowId]
- ) REFERENCES [DLShadowFiles] (
- [ServerId],
- [ShadowId]
- ),
- CONSTRAINT [FK_ShadowFiles_Users_Users] FOREIGN KEY
- (
- [ServerId],
- [UserId]
- ) REFERENCES [DLUsers] (
- [ServerId],
- [UserId]
- )
- GO
-
- ALTER TABLE [DLStations] ADD
- CONSTRAINT [FK_Stations_Servers] FOREIGN KEY
- (
- [ServerId]
- ) REFERENCES [DLServers] (
- [ServerId]
- ) ON UPDATE CASCADE
- GO
-
- ALTER TABLE [DLStore] ADD
- CONSTRAINT [FK_Store_Servers] FOREIGN KEY
- (
- [ServerId]
- ) REFERENCES [DLServers] (
- [ServerId]
- ) ON UPDATE CASCADE
- GO
-
- ALTER TABLE [DLStoreBin] ADD
- CONSTRAINT [FK_StoreBin_Servers] FOREIGN KEY
- (
- [ServerId]
- ) REFERENCES [DLServers] (
- [ServerId]
- ) ON UPDATE CASCADE ,
- CONSTRAINT [FK_StoreBin_Store] FOREIGN KEY
- (
- [ServerId],
- [StoreId]
- ) REFERENCES [DLStore] (
- [ServerId],
- [StoreId]
- ) NOT FOR REPLICATION
- GO
-
- ALTER TABLE [DLStoreUrl] ADD
- CONSTRAINT [FK_StoreUrl_Servers] FOREIGN KEY
- (
- [ServerId]
- ) REFERENCES [DLServers] (
- [ServerId]
- ) ON UPDATE CASCADE ,
- CONSTRAINT [FK_StoreUrl_Store] FOREIGN KEY
- (
- [ServerId],
- [StoreId]
- ) REFERENCES [DLStore] (
- [ServerId],
- [StoreId]
- ) NOT FOR REPLICATION
- GO
-
- ALTER TABLE [DLUsers] ADD
- CONSTRAINT [FK_Users_Servers] FOREIGN KEY
- (
- [ServerId]
- ) REFERENCES [DLServers] (
- [ServerId]
- ) ON UPDATE CASCADE
- GO
-
- ALTER TABLE [DLAuditLog] ADD
- CONSTRAINT [FK_DLAuditLog_DLServers] FOREIGN KEY
- (
- [ServerId]
- ) REFERENCES [DLServers] (
- [ServerId]
- ) ON UPDATE CASCADE ,
- CONSTRAINT [FK_DLAuditLog_DLStations] FOREIGN KEY
- (
- [ServerId],
- [CompId]
- ) REFERENCES [DLStations] (
- [ServerId],
- [CompId]
- ),
- CONSTRAINT [FK_DLAuditLog_DLUsers] FOREIGN KEY
- (
- [ServerId],
- [UserId]
- ) REFERENCES [DLUsers] (
- [ServerId],
- [UserId]
- )
- GO
-
- ALTER TABLE [DLSettings] ADD
- CONSTRAINT [FK_DLSettings_DLServers] FOREIGN KEY
- (
- [ServerId]
- ) REFERENCES [DLServers] (
- [ServerId]
- ) ON UPDATE CASCADE ,
- CONSTRAINT [FK_DLSettings_DLStations] FOREIGN KEY
- (
- [ServerId],
- [CompId]
- ) REFERENCES [DLStations] (
- [ServerId],
- [CompId]
- )
- GO
-